package com.yeskery.nut.web.demo.biz;

import com.yeskery.nut.annotation.bean.Component;
import com.yeskery.nut.extend.oauth.AuthorizationCodeAuthorizeRequest;
import com.yeskery.nut.extend.oauth.AuthorizationCodeGrantRequest;

/**
 * OAuthClientBiz
 * @author YESKERY
 * 2024/11/4
 */
@Component
public class OAuthClientBiz {

    /**
     * 校验客户端请求是否正确
     * @param request 客户端请求
     * @return boolean
     */
    public boolean checkClientAuthorizationCodeAuthorizeRequest(AuthorizationCodeAuthorizeRequest request) {
        return "nut-demo-client".equals(request.getClientId()) && request.getRedirectUri().startsWith("https://webhook.yeskery.com");
    }

    /**
     * 校验客户端请求是否正确
     * @param request 客户端请求
     * @return boolean
     */
    public boolean checkClientAuthorizationCodeGrantRequest(AuthorizationCodeGrantRequest request) {
        return "nut-demo-client".equals(request.getClientId())
                && "nut-demo-client-secret".equals(request.getClientSecret())
                && request.getRedirectUri().startsWith("https://webhook.yeskery.com");
    }
}
